package com.lxj.student_security.controller;

import com.lxj.student_security.common.CommonResult;
import com.lxj.student_security.entity.User;
import com.lxj.student_security.entity.vo.UserRoleRelation;
import com.lxj.student_security.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @PostMapping("/findAll")
    public CommonResult findAll(User user){
        return userService.findAll(user);
    }
    @PostMapping("/add")
    public CommonResult add(User user){
        return userService.add(user);
    }
    @PostMapping("/delete")
    public CommonResult delete(Integer[] id){
        return userService.delete(id);
    }
    /**
     * 根据用户id查询拥有角色
     */
    @PostMapping("/findByUserId")
    public CommonResult findRole(Integer id){
        return userService.findRole(id);
    }
    @PostMapping("/addRole")
    public CommonResult addRole(UserRoleRelation urr){
       return userService.addRole(urr);
    }
    @PostMapping("/deleteRole")
    public CommonResult deleteRole(UserRoleRelation urr){
        return userService.deleteRole(urr);
    }
}
